//
//  WeaponComposeLayer.h
//  FamousWarrior
//
//  Created by shuaixitao on 13-12-9.
//  Copyright (c) 2013年 Moqikaka. All rights reserved.
//

#ifndef __FamousWarrior__WeaponComposeLayer__
#define __FamousWarrior__WeaponComposeLayer__

#include "DetailLayer.h"
#include "CCTouchButton.h"
#include "WeaponData.h"
#include "CardNode.h"
#include "CCSliderView.h"

class WeaponComposeLayer: public DetailLayer, public CCSliderViewDataSource
{

public:
    static CCScene* scene();
    CREATE_FUNC(WeaponComposeLayer);
	
    WeaponComposeLayer();
	
	virtual ~WeaponComposeLayer();
	
	virtual bool init();
	
	virtual void onEnter();
	
	// CCSliderView协议
    CCSize middleItemSizeForSlider(CCSliderView *slider);
    void sliderItemAtIndex(CCSliderView *slider, CCSliderViewItem* item, int index);
    unsigned int itemCountOfSlider(CCSliderView *slider);
    void middleItemChanged(CCSliderView *slider, int newIndex);
    void sliderDidScrollBegin(CCSliderView *slider);
    void sliderDidScrollEnd(CCSliderView *slider);

	void onSliderItemPressed(CCMoveNode* node);
//	virtual void scrollViewDidScroll(CCScrollView* view){}
//    virtual void scrollViewDidZoom(CCScrollView* view) {}
//    virtual void tableCellTouched(CCTableView* table, CCTableViewCell* cell){}
//    virtual CCSize cellSizeForTable(CCTableView *table);
//    virtual CCTableViewCell* tableCellAtIndex(CCTableView *table, unsigned int idx);
//    virtual unsigned int numberOfCellsInTableView(CCTableView *table);
	
protected:
    //
    void setUi();
	
private:
	void refreshFragment();
	bool checkComposeCondition();
	void onBtnComposeClicked(CCTouchButton* pServer, CCTouchEvent evt);
private:
	CCSliderView* mSliderView;
	CardNode* mComposeCard;
	CCSize mSliderItemSize;
	bool mEnableSliderTouch;
	CCSprite* mSelFrame;
	int mCurSliderIdx;
};


#endif /* defined(__FamousWarrior__WeaponComposeLayer__) */
